<?php

namespace services\models;

/**
 * This is the ActiveQuery class for [[\common\models\BrandTable]].
 *
 * @see \common\models\BrandTable
 */
class BrandTableQuery extends \common\models\BrandTable
{
    public static function getDb() {
        return \Yii::$app->db;
    }
    
    public static function findQindexByGroupBy() {
        $var = self::find()->select('q_index')->where('q_index != ""')->groupBy('q_index')->all();
        return \yii\helpers\ArrayHelper::toArray($var);
    }
    
    public static function findGetAll() {
        $var = self::find()->select('brandname,id,logo,q_index')->where('is_show = 1')->groupBy('brandname')->limit(20)->all();
        return \yii\helpers\ArrayHelper::toArray($var);
    }
    
    public static function findBrandsById($id) {
        $var = self::find()->where('is_show = 1 AND id=:id',['id'=>$id])->one();
        return \yii\helpers\ArrayHelper::toArray($var);
    }
}
